#include <iostream>
using std::cout;
using std::endl;

class Base{
public:
    Base(long x)
    : _base(x)
    {}

    virtual 
    void display() const{
        cout << "Base::display()" << endl;
    }
private:
    long _base;
};


class Derived
: public Base
{
public:
    Derived(long base,long derived)
    : Base(base)
    , _derived(derived)
    {}

    /* virtual */ 
    void display() const override{
        cout << "Derived::display()" << endl;
    }
private:
    long _derived;
};

void test0(){
    cout << sizeof(Base) << endl;
    cout << sizeof(Derived) << endl;


    Derived d1(4,8);
    Base * pb = &d1;
    //基类指针指向派生类对象
    //只能访问派生类对象中基类子对象的部分
    /* pb->_base; */
    /* pb->_derived; */
    pb->display();

    //理解为隐藏
    d1.display();
}

int main(void){
    test0();
    return 0;
}
